import java.util.LinkedList;
import java.util.Queue;

public class Solution225 {

    Queue<Integer> queue=new LinkedList<>();

    public Solution225() {

    }

    public void push(int x) {
        queue.offer(x);
        for (int i=0;i<queue.size()-1;i++){
            queue.offer(queue.poll());
        }
    }

    public int pop() {
        return queue.poll();
    }

    public int top() {
        return queue.peek();
    }

    public boolean empty() {
        return queue.isEmpty();
    }

    public static void main(String[] args) {
        Solution225 solution225=new Solution225();
        solution225.push(1);
        solution225.push(2);
        System.out.println(solution225.top());
        System.out.println(solution225.pop());
        System.out.println(solution225.empty());
    }
}
